import request from 'umi-request';

export async function getSupplementList(params) {
  // return request('/hr-ssc/api/api-admin/leave/getShiftList', {
  //   method: 'get',
  //   params:{
  //     pageNum: params.current,
  //     ...params
  //   },
  // }).then((res) => {
  //   if (res.flag) {
  //     const data = res.data;
  //     return {
  //       current: data.currPage,
  //       data: data.list,
  //       pageSize: data.pageSize,
  //       success: true,
  //       total: data.totalCount,
  //     };
  //   } else {
  //     return {};
  //   }
  // });
  return {};
}

export async function getOvertimeApplyList(params) {
  return request('/hr-ssc/api/api-admin/employeeOverwork/listEmployeeOverWorkHr', {
    method: 'get',
    params:{
      pageNum: params.current,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getDistributeLeaveList(params) {
  return request('/hr-ssc/api/api-admin/leave/getDistributeLeaveList', {
    method: 'post',
    data:{
      ...params,
      pageNum: params.current,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getEndHolidayList(params) {
  return request('/hr-ssc/api/api-admin/reportBack/listReportSearch', {
    method: 'get',
    params:{
      pageNum: params.current,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getOvertimeSporadicList(params) {
  return request('/hr-ssc/api/api-admin/employeeOverworkOdd/listOverWorkOdd', {
    method: 'get',
    params:{
      pageNum: params.current,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function deleteOdd(id){
  return request('/hr-ssc/api/api-admin/employeeOverworkOdd/deleteOdd', {
    method: 'delete',
    params:{id},
  }).then(res => res);
}

export async function saveOdd(params) {
  return request(`/hr-ssc/api/api-admin/employeeOverworkOdd/saveOdd`, {
    method: 'post',
    data: {...params,status:1}
  }).then((res) => {
    return res;
  });
}

export async function overWorkOddBpm(id) {
  return request(`/hr-ssc/api/api-admin/bpm/overWorkOddBpm`, {
    method: 'post',
    data: {id},
    requestType: 'form'
  }).then((res) =>{
    return res;
  });
}
